package com.zrgg.futuwen;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.google.gson.Gson;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMWeb;
import com.zrgg.futuwen.alipay.AlipayPayTool;
import com.zrgg.futuwen.alipay.PayResult;
import com.zrgg.futuwen.base.SimpleActivity;
import com.zrgg.futuwen.base.bottomsheet.GCActionSheetDialog;
import com.zrgg.futuwen.contract.MainContract;
import com.zrgg.futuwen.network.data_model.FaceData;
import com.zrgg.futuwen.network.data_model.ShareData;
import com.zrgg.futuwen.network.data_model.ShareRetToJs;
import com.zrgg.futuwen.network.data_model.UpImgToJs;
import com.zrgg.futuwen.network.data_model.UpSoundToJs;
import com.zrgg.futuwen.presenter.MainPresenter;
import com.zrgg.futuwen.utils.Logger;
import com.zrgg.futuwen.widget.SoundRecordDialog;
import com.zrgg.futuwen.wxapi.PayMode;
import com.zrgg.futuwen.wxapi.PayTools;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

import cn.finalteam.galleryfinal.FunctionConfig;
import cn.finalteam.galleryfinal.GalleryFinal;
import cn.finalteam.galleryfinal.model.PhotoInfo;

@SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends SimpleActivity<MainPresenter> implements MainContract.View, View.OnClickListener {
    public static final int GET_IMG = 1;//获取图片
    public static final int GET_SOUD = 2;//获取声音
    View layoutRoot;
    View btnShare;
    private WebView mWebView;
    private String mUrl;
    private String mStrIimageFilename;//拍摄的地址
    private View layoutTitle;
    private TextView textTitle;
    private BaseInterface baseInterface;

    @Override
    protected int getLayout() {
        return R.layout.activity_main;
    }

    ProgressBar progressBar;


    public void synCookies(Context context) {
        CookieSyncManager.createInstance(context);
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptCookie(true);
        CookieSyncManager.getInstance().sync();
    }


    @Override
    protected void initEventAndData() {
        progressBar = (ProgressBar) findViewById(R.id.mscwebactivity__progressbar);
        presenter = new MainPresenter(this);
        layoutRoot = findViewById(R.id.layoutRoot);
        layoutTitle = findViewById(R.id.layoutTitle);
        btnShare = findViewById(R.id.btnShare);
        textTitle = (TextView) findViewById(R.id.textTitle);
        findViewById(R.id.imgBack).setOnClickListener(this);
        btnShare.setOnClickListener(this);

        //绑定微信支付监听广播
        IntentFilter filter = new IntentFilter(WPaySucc);
        LocalBroadcastManager.getInstance(this).registerReceiver(payReceiver, filter);

        mWebView = (WebView) findViewById(R.id.webview);
        //启用支持javascript
        WebSettings settings = mWebView.getSettings();
        settings.setJavaScriptEnabled(true);
        //支持多种分辨率，需要js网页支持
        //settings.setUserAgentString("mac os");
        String userAgentString = settings.getUserAgentString() + "/" + BuildConfig.user_agent;
        settings.setUserAgentString(userAgentString);
        settings.setDefaultTextEncodingName("utf-8");

        synCookies(this);

        mWebView.setWebViewClient(new WebViewClient() {

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                Logger.out(getOut(Urltool.getHost()));
                Logger.out(getOut(url));
                Logger.out(getOut(Urltool.getOuthHost(url)));
                // 拦截与接口返回不同的域名
                if (!Urltool.getHost().equalsIgnoreCase(Urltool.getOuthHost(url))) {
                    Uri uri = Uri.parse(url);
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    getActivity().startActivity(intent);

                    return true;
                } else {

                    return super.shouldOverrideUrlLoading(view, url);
                }


            }
        });
        mWebView.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                progressBar.setProgress(newProgress);
                if (newProgress >= 99) {
                    setTitle(view.getTitle());
                    progressBar.setVisibility(View.GONE);
                } else {
                    progressBar.setVisibility(View.VISIBLE);
                }
            }


        });
        baseInterface = new BaseInterface(MainActivity.this);
        mWebView.addJavascriptInterface(baseInterface, "androiduser");
//        优先使用缓存
        mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
//        不使用缓存：
//        mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

        //获取地址
        presenter.getMainUrl();
        //mWebView.loadUrl("https://www.baidu.com/");
        //mWebView.loadUrl("http://test.futuwen.com/app/foo/test");
        //mWebView.loadUrl("http://test.futuwen.com");

//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//
//                try {
//                    Thread.sleep(2000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//
//                runOnUiThread(new Runnable() {
//                    @Override
//                    public void run() {
//                        baseInterface.uploadfaceimg("");
//                    }
//                });
//
//            }
//        }).start();

    }

//    private void uploadImgJS() {
//        mWebView.loadUrl("javascript:uploadimgcallback('')");
//    }


    /**
     * 保存文件
     *
     * @param bm
     * @throws IOException
     */
    public void saveFile(Bitmap bm, File file) throws IOException {

        if (file.isFile()) {
            file.delete();
        }

        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
        bm.compress(Bitmap.CompressFormat.JPEG, 90, bos);
        bos.flush();
        bos.close();
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (mWebView.canGoBack()) {
                mWebView.goBack();//返回上一页面
                return true;
            } else {
                finish();
            }
        }
        return super.onKeyDown(keyCode, event);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.imgBack:
                if (mWebView.canGoBack()) {
                    mWebView.goBack();//返回上一页面
                } else {
                    finish();//退出程序
                }
                break;
            case R.id.btnShare:
                if (baseInterface != null) baseInterface.openShare();
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        handler.removeCallbacksAndMessages(null);
        baseInterface.onDestroy();
        baseInterface = null;
    }

    //获取首页返回数据
    @Override
    public void getMainUrlRet(String url) {

        Logger.out(getOut(url));

        if (!url.contains("://")) {
            url = BuildConfig.API_URL + url;
        }

        Logger.out(getOut(url));

//        Map map = new HashMap();
//        map.put("user_agent","fds_qb_android");

        mWebView.loadUrl(url);
    }


    //获取取图拍照的配置
    private FunctionConfig getImgConfig(int num) {
        FunctionConfig config = new FunctionConfig.Builder()
                .setMutiSelectMaxSize(num)
                .setMutiSelect(true)
                .setEnableRotate(true)
                .setEnablePreview(true)
                .setEnableEdit(true)
                .setEnableCrop(true)
                .build();
        return config;
    }

    //取图拍照监听
    private GalleryFinal.OnHanlderResultCallback onHanlderResultCallback = new GalleryFinal.OnHanlderResultCallback() {
        public void onHanlderSuccess(int reqeustCode, List<PhotoInfo> resultList) {
            int size = resultList.size();
            if (size > 0) {
                MainActivity.this.resultList = resultList;
                upIdx = 0;
                urlList = new ArrayList<>();
                startUpImg();
            }
        }

        public void onHanlderFailure(int requestCode, String errorMsg) {
        }
    };

    public void showToast(String msg) {
        dismissDialog();
        super.showToast(msg);
    }

    private List<PhotoInfo> resultList;//上传图片列表
    private int upIdx;//上传图片位置
    private List<String> urlList;//上传图片成功后的url

    //开始上传图片
    private void startUpImg() {
        int size = resultList.size();
        if (upIdx >= size) {//上传结束
            String s = new Gson().toJson(new UpImgToJs(urlList));

            // 普通的上传图片

            //告诉js上传成功后的url
            mWebView.loadUrl("javascript:uploadimgcallback(" + s + ")");

        } else {
            showDialog("正在上传（" + (upIdx + 1) + "/" + size + "）");
            PhotoInfo photoInfo = resultList.get(upIdx);
            String photoPath = photoInfo.getPhotoPath();
            presenter.upDataImg(photoPath);
        }
    }

    public static Context context;

    //上传图片成功返回
    public void upDataImgSucc(String url) {
        urlList.add(url);
        upIdx++;
        startUpImg();
    }


    //上传音频成功返回
    public void upDataSoundSucc(String url) {
        String s = new Gson().toJson(new UpSoundToJs(url));
        mWebView.loadUrl("javascript:uploadsoundcallback(" + s + ")");
    }

    //分享授权(貌似不需要)
    //public void platformInfo() {
    //UMShareAPI.get(this).getPlatformInfo(this, share_media, authListener);}
    //分享配置(貌似不需要)
    //public void setShare() {
    //UMShareConfig config = new UMShareConfig();
    //config.isNeedAuthOnGetUserInfo(false);
    //config.isOpenShareEditActivity(true);
    //config.setSinaAuthType(UMShareConfig.AUTH_TYPE_SSO);}

    //分享数据缓存
    private ShareRetToJs shareRetToJs;
    //分享结果回调
    public UMShareListener shareListener = new UMShareListener() {
        public void onStart(SHARE_MEDIA share_media) {
        }

        public void onResult(SHARE_MEDIA share_media) {
            if (Logger.isDebug) {
                showToast("分享成功");
            }
            if (shareRetToJs == null) return;
            String s = new Gson().toJson(shareRetToJs);
            mWebView.loadUrl("javascript:sharecallback(" + s + ")");
        }

        public void onError(SHARE_MEDIA share_media, Throwable throwable) {
            showToast("分享失败");
            shareRetToJs = null;
            if (Logger.isDebug && throwable != null) throwable.printStackTrace();
        }

        public void onCancel(SHARE_MEDIA share_media) {
            showToast("分享取消");
            shareRetToJs = null;
        }
    };

    MediaMetadataRetriever mMetadataRetriever;

    File videofile;

    final int maxvideotime = 8;

    // ms
    long videoalltime;


    // 人脸识别完成并返回
    @Override
    public void facerecognition(FaceData faceData) {
        String s = new Gson().toJson(faceData);
        mWebView.loadUrl("javascript:facecallback(" + s + ")");
    }


    @Override
    protected void onResume() {
        super.onResume();

        context =this;


        if (videofile != null && userid != null && videofile.isFile()) {
            mMetadataRetriever = new MediaMetadataRetriever();
            //2.设置视频源文件
            mMetadataRetriever.setDataSource(videofile.getAbsolutePath());

//3.获取视频的宽
            String w = mMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
            //获取视频的高
            String h = mMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
            //获取视频的时长，ms
            videoalltime = Long.parseLong(mMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
            showDialog("身份识别中");
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Bitmap bitmap = extractFrame(new Random().nextInt((maxvideotime - 1) * 1000));
                    videofile = null;

                    File bitfiledir = getExternalFilesDir("bit");


                    final File bitfile = new File(bitfiledir, System.currentTimeMillis() + ".png");

                    try {
                        saveFile(bitmap, bitfile);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {

                            // 人脸识别开始
                            if (bitfile.isFile()) {
                                presenter.facerecognition(bitfile, userid);
                            }


                            userid = null;
                        }
                    });

// 等等...一些其它属性，比如媒体类型（3gp,mp4) ,视频旋转角度
//4.释放资源，防止内存泄漏，养成好习惯
                    mMetadataRetriever.release();

                }
            }).start();


        }

    }


    //分享授权返回
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);

        if (resultCode == RESULT_OK && requestCode == Activity.RESULT_OK) {

            Logger.out(data.toString());

        }

    }


    public Bitmap extractFrame(long timeMs) {
        //第一个参数是传入时间，只能是us(微秒)
        //OPTION_CLOSEST ,在给定的时间，检索最近一个帧,这个帧不一定是关键帧。
        //OPTION_CLOSEST_SYNC  在给定的时间，检索最近一个同步与数据源相关联的的帧（关键帧）
        //OPTION_NEXT_SYNC 在给定时间之后检索一个同步与数据源相关联的关键帧。
        //OPTION_PREVIOUS_SYNC 在给定时间之前检索一个同步与数据源相关联的关键帧。

// Bitmap bitmap = mMetadataRetriever.getFrameAtTime(timeMs * 1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
        Bitmap bitmap = null;
        for (long i = timeMs; i < videoalltime; i += 1000) {
            bitmap = mMetadataRetriever.getFrameAtTime(i * 1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
            if (bitmap != null) {
                break;
            }
        }
        return bitmap;
    }


    //-----------------------------------支付有关-----------------------------------
    //支付宝支付>>>
    public void aPayStart(String alipay) {
        AlipayPayTool alipayPayTool = new AlipayPayTool(this, alipay);
        alipayPayTool.setHandler(handler);
        alipayPayTool.start();
    }

    //支付宝支付回调handler
    private Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case 1: {
                    PayResult payResult = new PayResult((Map<String, String>) msg.obj);
                    /**
                     * 同步返回的结果必须放置到服务端进行验证（验证的规则请看https://doc.open.alipay.com/doc2/
                     * detail.htm?spm=0.0.0.0.xdvAU6&treeId=59&articleId=103665&
                     * docType=1) 建议商户依赖异步通知
                     */
                    String resultInfo = payResult.getResult();// 同步返回需要验证的信息
                    String resultStatus = payResult.getResultStatus();
                    // 判断resultStatus 为“9000”则代表支付成功，具体状态码代表含义可参考接口文档
                    if (TextUtils.equals(resultStatus, "9000")) {
                        showToast("支付成功...");
                        Logger.out("支付成功...");
                        // TODO 支付成功后不知道做什么了
//                        Intent intent2 = new Intent();
//                        intent2.setClassName(getActivity(), to);
//                        intent2.putExtra("isPay", true);
//                        intent2.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
//                        startActivity(intent2);
                    } else {
                        // 判断resultStatus 为非"9000"则代表可能支付失败
                        // "8000"代表支付结果因为支付渠道原因或者系统原因还在等待支付结果确认，最终交易是否成功以服务端异步通知为准（小概率状态）
                        if (TextUtils.equals(resultStatus, "8000")) {
                            Logger.out("支付结果确认中...");
                            showToast("支付结果确认中...");
                        } else {
                            Logger.out("支付失败...");
                            // 其他值就可以判断为支付失败，包括用户主动取消支付，或者系统返回的错误
                            showToast("支付失败...");
                        }
                    }
                    break;
                }
            }
        }
    };


    //微信支付>>>
    public void wPayStart(PayMode payMode) {
        PayTools payTools = new PayTools(this);
        payTools.payStart(payMode);
    }


    //这儿是监听微信支付结果
    public static final String WPaySucc = "com.zrgg.futuwen.WPaySucc";
    private BroadcastReceiver payReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            if (intent.getBooleanExtra("isPay", false)) {
                // TODO 支付成功后不知道做什么了
            }
        }
    };

    // 用户id
    static String userid;

    //-----------------------------------支付有关-----------------------------------

    public class BaseInterface implements SoundRecordDialog.OnSoundRecordListener {
        SimpleActivity activity;

        public BaseInterface(SimpleActivity activity) {
            this.activity = activity;
        }

        public void onDestroy() {
            activity = null;
        }

        @JavascriptInterface
        public void uploadimg(String method) {
            uploadimg(method, 1);
        }

        @JavascriptInterface
        public void uploadfaceimg(String userid) {
            MainActivity.userid = userid;

            File mp4filedir = getExternalFilesDir("mp4");

            if (!mp4filedir.isDirectory()) {
                mp4filedir.mkdirs();
            }


            videofile = new File(mp4filedir, System.currentTimeMillis() + ".mp4");

            if (videofile.isFile()) {
                videofile.delete();
            }


            Uri videouri = Uri.fromFile(videofile);
            startgetcam(maxvideotime, videouri);

        }






        @JavascriptInterface
        public void uploadimg(final String method, final int num) {
            handler.post(new Runnable() {
                public void run() {
                    openImgSelect(method, num);
                }
            });
        }

        public void openImgSelect(String method, final int num) {
            if (TextUtils.isEmpty(method)) return;
            final GCActionSheetDialog dialog = new GCActionSheetDialog(activity).builder()
                    .setCancelable(false)
                    .setCanceledOnTouchOutside(false);
            int i = 0;
            if (method.contains("s")) {//本地
                i = 1;
            }
            if (method.contains("p")) {//拍摄
                i += 2;
            }
            if ((i & 1) > 0) {
                dialog.addSheetItem(getString(R.string.poi_file_image), GCActionSheetDialog.SheetItemColor.ALBUM
                        , R.drawable.actionsheet_camera,
                        new GCActionSheetDialog.OnSheetItemClickListener() {
                            public void onClick(int which) {
                                //SystemUtil.openFileImage(MainActivity.this);
                                FunctionConfig imgConfig = getImgConfig(num);
                                GalleryFinal.openGalleryMuti(GET_IMG, imgConfig, onHanlderResultCallback);
                            }
                        });
            }
            if ((i & 2) > 0) {
                dialog.addSheetItem(getString(R.string.poi_camera), GCActionSheetDialog.SheetItemColor.PHOTO
                        , R.drawable.actionsheet_photo,
                        new GCActionSheetDialog.OnSheetItemClickListener() {
                            public void onClick(int which) {
                                if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                                    //申请权限，REQUEST_TAKE_PHOTO_PERMISSION是自定义的常量
                                    ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
                                } else {
                                    //有权限，直接拍照
                                    //takephone();
                                    FunctionConfig imgConfig = getImgConfig(num);
                                    GalleryFinal.openCamera(GET_IMG, imgConfig, onHanlderResultCallback);
                                }
                            }
                        });
            }
            if (i > 0) dialog.show();
            Logger.out("uploadimg");
        }

        @JavascriptInterface
        public void uploadsound(String method) {//上传声音
            handler.post(new Runnable() {
                public void run() {
                    new SoundRecordDialog(MainActivity.this).setOnSoundRecordListener(BaseInterface.this).showPopupWindow(layoutRoot);
                }
            });
        }

        //保存即将分享的数据
        @JavascriptInterface
        public void resetshare(String share_title, String share_desc, String share_img, String linkurl) {
            if (TextUtils.isEmpty(share_title) || TextUtils.isEmpty(share_desc) ||
                    TextUtils.isEmpty(share_img) || TextUtils.isEmpty(linkurl))
                return;
            shareData = new ShareData(share_title, share_desc, share_img, linkurl);
            btnShare.post(new Runnable() {
                public void run() {
                    if (btnShare.getVisibility() != View.VISIBLE) {
                        btnShare.setVisibility(View.VISIBLE);
                    }
                }
            });
        }

        public ShareData shareData;

        public void openShare() {//开启分享
            if (shareData == null) {
                showToast("暂无分享数据");
                return;
            }

            shareRetToJs = new ShareRetToJs(shareData.share_title, shareData.share_desc, shareData.share_img, shareData.linkurl);
            UMImage umImage = new UMImage(MainActivity.this, shareData.share_img);
            UMWeb web = new UMWeb(shareData.linkurl);
            web.setTitle(shareData.share_title);//标题
            web.setThumb(umImage);  //缩略图
            web.setDescription(shareData.share_desc);//描述

            new ShareAction(MainActivity.this).withMedia(web)
                    .setDisplayList(SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE/*, SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE, SHARE_MEDIA.SINA*/)
                    .setCallback(shareListener).open();
        }

        //录音成功返回
        public void onSoundRecord(String fileStr) {
            presenter.upDataSound(fileStr);
        }

        //设置标题
        @JavascriptInterface
        public void resetitle(final String title) {
            handler.post(new Runnable() {
                public void run() {

                    setTitle(title);
                }
            });
        }

    }


    private void setTitle(String title) {
        if (TextUtils.isEmpty(title) || title.length() > 8) {
            layoutTitle.setVisibility(View.GONE);
        } else {
            layoutTitle.setVisibility(View.VISIBLE);
            textTitle.setText(title);
        }
    }

    /**
     * @param miao 录制视频最大多长时间
     * @RESULT_OK RESULT_OK
     **/
    public void startgetcam(int miao, Uri temppath) {

        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        // 设置输出为mp4
        intent.putExtra(MediaStore.EXTRA_OUTPUT, temppath);
        // 1 是最高清晰
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

        // 设置视频大小 720*1280
        intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 720 * 1280);

        // 设置视频时间 毫秒单位
        intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, miao);

        startActivityForResult(intent, Activity.RESULT_OK);

        showToast("请录制" + miao + "秒视频完成验证");

    }

//    private void takephone() {
//        String saveImageDir = GCResPathCenter.getInstance().getImageFilePath();
//        File file = new File(saveImageDir);
//        if (!file.exists()) {
//            if (!file.mkdirs()) {
//                return;
//            }
//        }
//        mStrIimageFilename = saveImageDir + File.separator + SystemUtil.produceFile();
//        SystemUtil.cameraMethod(this, GCResPathCenter.getInstance().getImageFilePath(), mStrIimageFilename);
//    }
}
